package com.fresh.consumer;

import com.fresh.entity.Pay;
import com.fresh.service.YingFuKuanService;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.io.IOException;

@Component
public class OrderConsumer {
    @Autowired
    YingFuKuanService yingFuKuanService;

    @RabbitListener(queues = "queueOrderDLX")
    public void receiveQueueOrderDLX(Pay pay, Message message, Channel channel) throws IOException {
        yingFuKuanService.pay(pay);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }

/*    @RabbitListener(queues = "queueDelay")
    public void receiveQueueDelay(Pay pay, Message message, Channel channel) throws IOException {
        yingFuKuanService.pay(pay);
        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
    }*/

}
